/**
 * JAVACC DEMO 1.0
 */
package com.apache.uct.service.plugins;

import com.apache.api.manager.PluginConnector;
import com.apache.api.vo.ParamsVo;
import com.apache.api.vo.ResultEntity;
import com.apache.uct.manager.ActManager;
import org.apache.log4j.Logger;

/**
 * description:  机构属性查询
 *
 * @author iussoft 创建时间：2016-4-1
 */
public class ActEntityPlugin implements PluginConnector {

    private Logger log = Logger.getLogger(ActEntityPlugin.class);

    private ActManager actManager;

    /**
     * TODO 机构属性查询插件(按权限ID或英文全称).<br>
     * 参数说明:<br>
     * propertyName:属性名称<br>
     * propertyValue:属性值
     */
    public Object execute(ParamsVo vo) throws Exception {

        ResultEntity result = new ResultEntity();
        try {
            result.setResult("true");
            String propertyName = String.valueOf(vo.getParams("propertyName"));
            String propertyValue = String.valueOf(vo.getParams("propertyValue"));
            if ("actId".equals(propertyName) || "fullEname".equals(propertyName)) {
                ParamsVo pvo = new ParamsVo();
                pvo.setParams("propertyName", propertyName);
                pvo.setParams("propertyValue", propertyValue);
                pvo.setKey("ByActProperty");
                result.setEntity(actManager.execute(pvo));
                result.setMessage("查询成功");
            } else {
                result.setMessage("不支持[" + propertyName + "]属性查询");
            }
        } catch (Exception e) {
            result.setResult("false");
            log.error("执行机构查询失败 ", e);
            result.setMessage("机构查询失败！");
        }
        return result;
    }

    public void setActManager(ActManager actManager) {
        this.actManager = actManager;
    }

}
